home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CDictionary 1.0 / CDictTestApp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  3.1 KB  |  166 lines  |  [TEXT/KAHL]

  1. /*****
  2.  * CDictTestApp.c
  3.  *
  4.  *    Application methods for a typical application.
  5.  *
  6.  *****/
  7.  
  8. #include "CDictTestApp.h"
  9. #include "CDictTestDoc.h"
  10.  
  11. extern    OSType    gSignature;
  12.  
  13. /***
  14.  * IDictTestApp
  15.  *
  16.  *    Initialize the application. Your initialization method should
  17.  *    at least call the inherited method. If your application class
  18.  *    defines its own instance variables or global variables, this
  19.  *    is a good place to initialize them.
  20.  *
  21.  ***/
  22.  
  23. void CDictTestApp::IDictTestApp(void)
  24.  
  25. {
  26.     CApplication::IApplication(30, 32767L, 2048L);
  27. }
  28.  
  29.  
  30.  
  31. /***
  32.  * SetUpFileParameters
  33.  *
  34.  *    In this routine, you specify the kinds of files your
  35.  *    application opens.
  36.  *
  37.  *
  38.  ***/
  39.  
  40. void CDictTestApp::SetUpFileParameters(void)
  41.  
  42. {
  43.     inherited::SetUpFileParameters();    /* Be sure to call the default method */
  44.  
  45.     sfNumTypes = 1;
  46.     sfFileTypes[0] = 'DICT';
  47.  
  48.  
  49.     gSignature = 'danp';
  50. }
  51.  
  52.  
  53.  
  54. /***
  55.  * DoCommand
  56.  *
  57.  *    Your application will probably handle its own commands.
  58.  *    Remember, the command numbers from 1-1023 are reserved.
  59.  *    The file Commands.h contains all the reserved commands.
  60.  *
  61.  *    Be sure to call the default method, so you can get
  62.  *    the default behvior for standard commands.
  63.  *
  64.  ***/
  65. void CDictTestApp::DoCommand(long theCommand)
  66.  
  67. {
  68.     switch (theCommand) {
  69.     
  70.         /* Your commands go here */
  71.     
  72.         default:    inherited::DoCommand(theCommand);
  73.                     break;
  74.     }
  75. }
  76.  
  77. /***
  78.  * Exit
  79.  *
  80.  *    Chances are you won't need this method.
  81.  *    This is the last chance your application gets to clean up
  82.  *    things like temporary files.
  83.  *
  84.  ***/
  85.  
  86. void CDictTestApp::Exit()
  87.  
  88. {
  89.     /* your exit handler here */
  90. }
  91.  
  92.  
  93. /***
  94.  * CreateDocument
  95.  *
  96.  *    The user chose New from the File menu.
  97.  *    In this method, you need to create a document and send it
  98.  *    a NewFile() message.
  99.  *
  100.  ***/
  101.  
  102. void CDictTestApp::CreateDocument()
  103.  
  104. {
  105.     CDictTestDoc    *theDocument;
  106.     
  107.     theDocument = new(CDictTestDoc);
  108.         
  109.         /**
  110.          **    Send your document an initialization
  111.          **    message. The first argument is the
  112.          **    supervisor (the application). The second
  113.          **    argument is TRUE if the document is printable.
  114.          **
  115.          **/
  116.     
  117.     theDocument->IDictTestDoc(this, TRUE);
  118.  
  119.         /**
  120.          **    Send the document a NewFile() message.
  121.          **    The document will open a window, and
  122.          **    set up the heart of the application.
  123.          **
  124.          **/
  125.     theDocument->NewFile();
  126. }
  127.  
  128. /***
  129.  * OpenDocument
  130.  *
  131.  *    The user chose Open… from the File menu.
  132.  *    In this method you need to create a document
  133.  *    and send it an OpenFile() message.
  134.  *
  135.  *    The macSFReply is a good SFReply record that contains
  136.  *    the name and vRefNum of the file the user chose to
  137.  *    open.
  138.  *
  139.  ***/
  140.  
  141. void CDictTestApp::OpenDocument(SFReply *macSFReply)
  142.  
  143. {
  144.     CDictTestDoc    *theDocument;
  145.     
  146.     theDocument = new(CDictTestDoc);
  147.         
  148.         /**
  149.          **    Send your document an initialization
  150.          **    message. The first argument is the
  151.          **    supervisor (the application). The second
  152.          **    argument is TRUE if the document is printable.
  153.          **
  154.          **/
  155.     
  156.     theDocument->IDictTestDoc(this, TRUE);
  157.  
  158.         /**
  159.          **    Send the document an OpenFile() message.
  160.          **    The document will open a window, open
  161.          **    the file specified in the macSFReply record,
  162.          **    and display it in its window.
  163.          **
  164.          **/
  165.     theDocument->OpenFile(macSFReply);
  166. }